
from selenium import webdriver
from time import sleep
# 实现无可视化界面
from selenium.webdriver.chrome.options import Options

# 实现规避检测
from selenium.webdriver import ChromeOptions

# 实例化Options对象，实现无可视化界面
chrome_options = Options()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-gpu')

# 实现规避检测 实例化对象
option = ChromeOptions()
option.add_experimental_option('excludeSwitches', ['enable-automation'])


# 实例化浏览器对象,并添加chrome_options、options参数
# 如何规避被检测的风险

bro = webdriver.Chrome(executable_path='./chromedriver',chrome_options=chrome_options,options=option)
# 无可视化界面  phantoms 也是无可视化浏览器
bro.get('https://www.sougou.com')
# page_text = bro.page_source
print(bro.page_source)

sleep(2)
bro.quit()



















